package com.reden.enums;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public enum WeekEnum {
    SUNDAY(0, "周日", "日曜日"),
    MONDAY(1, "周一", "月曜日"),
    TUESDAY(2, "周二", "火曜日"),
    WEDNESDAY(3, "周三", "水曜日"),
    THURSDAY(4, "周四", "土曜日"),
    FRIDAY(5, "周五", "木曜日"),
    SATURDAY(6, "周六", "金曜日"),
    ;

    private Integer value;
    private String label;
    private String remark;

    public Integer getValue() {
        return value;
    }

    public String getLabel() {
        return label;
    }

    public String getRemark() {
        return remark;
    }

    WeekEnum(Integer value, String label, String remark) {
        this.value = value;
        this.label = label;
        this.remark = remark;
    }

    public static List<Map> getEnumAll() {
        List<Map> result = new LinkedList<>();
        for (WeekEnum e : WeekEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("name", e.name());
            map.put("value", e.getValue());
            map.put("label", e.getLabel());
            map.put("remark", e.getRemark());
            result.add(map);
        }
        return result;
    }

    public static WeekEnum getEnumByValue(Integer value) {
        if (value == null)
            return null;
        for (WeekEnum e : WeekEnum.values())
            if (value.equals(e.getValue()))
                return e;
        return null;
    }
}
